package org.datascooter.cglib.proxy;

import net.sf.cglib.proxy.Enhancer;

import org.datascooter.inface.IDataManager;

public class ObjectWrapper {

	@SuppressWarnings("unchecked")
	public static <T> T wrap(IDataManager manager, T obj) throws IllegalArgumentException, IllegalAccessException {
		manager.saveOrUpdate(obj);
		return (T) Enhancer.create(obj.getClass(), new SimpleInterceptor(null, obj, null, manager));
	}
}
